<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        li{
            line-height: 50px;
            background: rgb(129, 118, 118);
            margin-top:5px;
        }
    </style>
</head>
<body>
    <div id="app">
        <button @click="reduce">减少一个</button>
        <ul>
            <li v-for="(item,index) in arr" @click="change(index)" :key="index">
                {{item}}
            </li>
        </ul>
    </div>
    <script src="./vue.js"></script>
    <script>
        let vm = new Vue({
            el:"#app",
            data:{
                arr:[1,2,3,4]
            },
            methods:{
                reduce(){
                    this.arr.length = this.arr.length-1;
                    console.log(this.arr);
                },
                change(index){
                    // this.arr[index] = 100;
                    this.$set(this.arr,index,100)
                    console.log(this.arr);
                }
            }
        })
    </script>
</body>
</html>